<?php

class Validator
{
   private $_value;
   private $_validations;
   private $_errors;

   function __construct($value = "")
   {
      $this->_value = $value;
      $this->_validations = true;
      $this->_errors = array();
   }

   function checkMin($min)
   {
      if (strlen($this->_value) < $min)
      {
         $this->_validations = false;
      }  
   }
 
   function checkMax($max)
   {
      if (strlen($this->_value) > $max)
      {
         $this->_validations = false;
      } 
   }

   function checkMinMax($min, $max)
   {
      if (strlen($this->_value) > $max || strlen($this->_value) < $min)
      {
         $this->_validations = false;
      } 
   }
 
   function checkEmail()
   {
      if (eregi("^[^@[:space:]]+@([[:alnum:]-]+.)+[[:alnum:]][[:alnum:]][[:alnum:]]?$", $this->_value) == false) 
      { 
         $this->_validations = false; 
      } 
   }

   function checkRequired()
   {
      if ($this->_value == "")
      {
         $this->_validations = false;
      }
   }

   function clear()
   {
      $this->_validations = true;
   }

   function validate()
   {
      return $this->_validations;
   }
}

?>